package com.cxs.service.impl;

import com.cxs.mapper.DepartmentMapper;
import com.cxs.pojo.Department;
import com.cxs.service.DepartmentSevice;
import com.cxs.vo.DepartmentVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/*
 * @Author:cxs
 * @Date:2021/10/20  14:36
 * @Version 1.0
 * @Motto:放下杂念,只为迎接明天更好的自己
 * */
@Slf4j
@Service
public class DepartmentSeviceImpl implements DepartmentSevice {

    @Autowired
    private DepartmentMapper departmentMapper;

    @Override
    public List<DepartmentVO> findDepts() {
        List<Department> departments = departmentMapper.selectByExample(null);
        List<DepartmentVO> list = new ArrayList<>();
        departments.forEach(r ->{
            DepartmentVO vo = new DepartmentVO();
            BeanUtils.copyProperties(r,vo);
            list.add(vo);
        });
        return list;
    }
}
